package com.ruoyi.project.fire.controller;

import java.util.List;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.framework.aspectj.lang.annotation.Log;
import com.ruoyi.framework.aspectj.lang.enums.BusinessType;
import com.ruoyi.project.fire.domain.FireRiskPoint;
import com.ruoyi.project.fire.service.IFireRiskPointService;
import com.ruoyi.framework.web.controller.BaseController;
import com.ruoyi.framework.web.domain.AjaxResult;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.framework.web.page.TableDataInfo;

/**
 * 排查项目Controller
 * 
 * @author 布衣
 * @date 2025-05-13
 */
@RestController
@RequestMapping("/system/point")
public class FireRiskPointController extends BaseController
{
    @Autowired
    private IFireRiskPointService fireRiskPointService;

    /**
     * 查询排查项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:point:list')")
    @GetMapping("/list")
    public TableDataInfo list(FireRiskPoint fireRiskPoint)
    {
        startPage();
        List<FireRiskPoint> list = fireRiskPointService.selectFireRiskPointList(fireRiskPoint);
        return getDataTable(list);
    }

    /**
     * 导出排查项目列表
     */
    @PreAuthorize("@ss.hasPermi('system:point:export')")
    @Log(title = "排查项目", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, FireRiskPoint fireRiskPoint)
    {
        List<FireRiskPoint> list = fireRiskPointService.selectFireRiskPointList(fireRiskPoint);
        ExcelUtil<FireRiskPoint> util = new ExcelUtil<FireRiskPoint>(FireRiskPoint.class);
        util.exportExcel(response, list, "排查项目数据");
    }

    /**
     * 获取排查项目详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:point:query')")
    @GetMapping(value = "/{riskId}")
    public AjaxResult getInfo(@PathVariable("riskId") Long riskId)
    {
        return success(fireRiskPointService.selectFireRiskPointByRiskId(riskId));
    }

    /**
     * 新增排查项目
     */
    @PreAuthorize("@ss.hasPermi('system:point:add')")
    @Log(title = "排查项目", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody FireRiskPoint fireRiskPoint)
    {
        return toAjax(fireRiskPointService.insertFireRiskPoint(fireRiskPoint));
    }

    /**
     * 修改排查项目
     */
    @PreAuthorize("@ss.hasPermi('system:point:edit')")
    @Log(title = "排查项目", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody FireRiskPoint fireRiskPoint)
    {
        return toAjax(fireRiskPointService.updateFireRiskPoint(fireRiskPoint));
    }

    /**
     * 删除排查项目
     */
    @PreAuthorize("@ss.hasPermi('system:point:remove')")
    @Log(title = "排查项目", businessType = BusinessType.DELETE)
	@DeleteMapping("/{riskIds}")
    public AjaxResult remove(@PathVariable Long[] riskIds)
    {
        return toAjax(fireRiskPointService.deleteFireRiskPointByRiskIds(riskIds));
    }
}
